<title>Đăng Nhập - User Tools - Origami Shop Online | Origamishop.net</title>
<?php
	if(isset($_POST["buttonSubmit"]))
	{
		$id = $_POST["username"];
		$pass = md5($_POST["password"]);
		$cn="select * from user where username = '$id'";
		$rs=DataProvider::ExecuteQuery($cn);
		if(mysql_num_rows($rs) > 0)
		{
			while($us=mysql_fetch_array($rs))
			{
				if ($us["password"]==$pass)
				{
					if($us["block"]=='true')
					{
						header("location:home.php?typ=user&act=error&err=block");
					}
					else if($us["banned"]=='true')
					{
						header("location:home.php?typ=user&act=error&err=banned");
					}
					else
					{
						$_SESSION["IsLogin"]=true;
						$_SESSION["User"]=$us["username"];
						$admin=$us["admin"];
						if ($us["admin"]=='true')
						{
						$_SESSION["IsAdmin"]=true;
						header("location:index.php");
						}
						elseif ($us["admin"]=='false'||$us["admin"]=='')
						{
						$_SESSION["IsAdmin"]=false;
						header("location:index.php");
						}
					}
				}
				else
				{
					echo '
			<br><br><font style="font-size:15px">Sai password!</font><br><br>
			<form  method="post" action="'.$host["l_link"].'home.php?typ=user&act=exli" >
				Username:
				<input name="username" title="Username" size="30" maxlength="1024" />
				<br />
				Password:
				<input name="password" type="password" title="Password" size="30" maxlength="2048" />
				<br /><br />
				<input name="buttonSubmit" type="submit" value="Đăng Nhập"/>
			</form>
					';
				}
			}
		}
		else
		{
		header("location:home.php?typ=user&act=error&err=wrong");
		}
	}
?>
<?php
$strSQL = "SELECT * FROM count where count_id=1";
$result = DataProvider::ExecuteQuery($strSQL);
while($row1 = mysql_fetch_array($result)){
	$SQL = "update count set count_num=".($row1["count_num"]+1)." where count_id=1";
	$result_sql = DataProvider::ExecuteQuery($SQL);}
?>

